﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using VehicleRecordSystem.util;

namespace VehicleRecordSystem.view
{
    /// <summary>
    /// Interaction logic for SparepartPage.xaml
    /// </summary>
    public partial class SparepartPage : Page
    {
        public SparepartPage()
        {
            InitializeComponent();
        }

        private void btnSparepartPageSave_Click(object sender, RoutedEventArgs e)
        {
            if (validate())
            {
                String part_number=txtPartNumber.Text;
                String part_name=txtPartName.Text;
                String serial_number=txtSerialNumber.Text;
                String description = txtDescription.Text;
            }
        }
        private bool validate()
        {
            Boolean ok = true;
            if (string.IsNullOrEmpty(txtPartNumber.Text))
            {
                ok = false;
                GUI.changeBackgroundColorToError(txtPartNumber);
            }
            if (string.IsNullOrEmpty(txtPartName.Text))
            {
                ok = false;
                GUI.changeBackgroundColorToError(txtPartName);
            }
            if (string.IsNullOrEmpty(txtSerialNumber.Text))
            {
                ok = false;
                GUI.changeBackgroundColorToError(txtSerialNumber);
            }
            if (string.IsNullOrEmpty(txtDescription.Text))
            {
                ok = false;
                GUI.changeBackgroundColorToError(txtDescription);
            }
            return ok;
        }
        private void changeBackgroundColorToNormal(object sender, RoutedEventArgs e)
        {
            GUI.changeBackgroundColorToNormal(sender);
        }
    }
}
